//console.log(new Date().toLocaleString())

formatNumber = n => {
    n = n.toString()
    return n[1] ? n : '0' + n
}
fn = n => n.toString().padStart(2, 0)

// 时间格式化
ft = d => {
    const year = d.getFullYear()
    const month = d.getMonth() + 1
    const day = d.getDate()
    const hour = d.getHours()
    const minute = d.getMinutes()
    const second = d.getSeconds()
    return [[year, month, day].map(fn).join('-'), ' ', [hour, minute, second].map(fn).join(':')].join('')
}
//console.log(formatNumber(6), fn(6), fn(12))
//console.log(ft(new Date()))


//2023年03月31日 星期五
fd = d => {
    const [year, month, day] = [d.getFullYear(), fn(d.getMonth() + 1), fn(d.getDate())]
    return [year, '年', month, '月', day, '日', ' 星期', '日一二三四五六'[d.getDay()]].join('')
}
console.log(fd(new Date()))

//nt为java的时间戳
let nt = 1680242327159
console.log(nt)
console.log(new Date(nt).toLocaleString())
console.log(ft(new Date(nt)))



